# $Id: PKGBUILD 87854 2013-04-08 09:24:47Z spupykin $
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Rubin Simons <rubin@xs4all.nl>

pkgname=trac
pkgver=1.0.1
pkgrel=1
pkgdesc="Trac Integrated SCM & Project Management using Apache & Subversion."
arch=('any')
url="http://trac.edgewall.org/"
license=('BSD')
depends=(python2 setuptools python2-genshi python2-babel)
makedepends=(clearsilver)
install=trac.install
backup=("etc/conf.d/tracd.conf")
source=(http://ftp.edgewall.com/pub/trac/Trac-$pkgver.tar.gz
	license.txt
	tracd
	tracd.service
	tracd.conf)
md5sums=('c869fa40e29fa4597e2c9c960de9f2f3'
         'af9a4064fd7a5759fee0fc288f749977'
         '907d7bfeb5131f1bf7444b64d18e7eb2'
         '6dc659f6a4c0247173ae7fab4d8fee6e'
         '67db455554d661c725baf3057bd13534')

package() {
  cd $srcdir/Trac-$pkgver

  # python2 fix
  for file in trac/admin/console.py trac/test.py trac/tests/functional/*.py \
              trac/web/*.py trac/wiki/default-pages/TracFastCgi \
              contrib/cgi-bin/trac.{f,}cgi; do
      sed -i 's_#!/usr/bin/env python_#!/usr/bin/env python2_' $file
      sed -i 's_#!/usr/bin/python_#!/usr/bin/python2_' $file
  done

  python2 setup.py install --prefix=/usr --root=$pkgdir
  install -D -m755 ../tracd $pkgdir/etc/rc.d/tracd
  install -D -m644 ../tracd.conf $pkgdir/etc/conf.d/tracd.conf
  install -D -m644 ../license.txt $pkgdir/usr/share/licenses/trac/license.txt
  install -D -m0755 contrib/cgi-bin/trac.cgi $pkgdir/usr/share/trac/trac.cgi
  install -D -m0755 contrib/cgi-bin/trac.fcgi $pkgdir/usr/share/trac/trac.fcgi
  install -Dm0644 $srcdir/tracd.service $pkgdir/usr/lib/systemd/system/tracd.service
}
